﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using ClearUnit.TestRunners.Results;
using System.IO;

namespace ClearUnit.TestRunners
{
    class ConsoleRunner
    {
        static void Main()
        {
            var args = Environment.GetCommandLineArgs();

            if (args.Length != 2)
            {
                string entryPointPath = args[0];
                Console.WriteLine("Usage: {0} <assemblyPath>", Path.GetFileName(entryPointPath));
            }
            else
            {
                string assemblyPath = args[1];
                var clearUnitTests = Assembly.LoadFile(assemblyPath);

                Action<TestRunInfo> eventListener = e =>
                    {
                        if (e is TestRunResult)
                            Console.WriteLine(e.ShortDescription);
                    };

                var result = new AssemblyRunner(clearUnitTests, eventListener).Run();
            }

            Console.WriteLine("Press ENTER to finish");
            Console.ReadLine();
        }
    }
}
